document.addEventListener('DOMContentLoaded', function() {
    // 名言轮播
    const quoteSlides = document.querySelectorAll('.quote-slide');
    if (quoteSlides.length > 0) {
        const prevBtn = document.querySelector('.quote-prev');
        const nextBtn = document.querySelector('.quote-next');
        let currentQuote = 0;

        function showQuote(index) {
            quoteSlides.forEach(slide => slide.classList.remove('active'));
            quoteSlides[index].classList.add('active');
        }

        function nextQuote() {
            currentQuote = (currentQuote + 1) % quoteSlides.length;
            showQuote(currentQuote);
        }

        function prevQuote() {
            currentQuote = (currentQuote - 1 + quoteSlides.length) % quoteSlides.length;
            showQuote(currentQuote);
        }

        if (prevBtn && nextBtn) {
            prevBtn.addEventListener('click', prevQuote);
            nextBtn.addEventListener('click', nextQuote);
        }

        // 自动轮播
        let quoteInterval = setInterval(nextQuote, 5000);

        // 鼠标悬停时暂停轮播
        const quotesWrapper = document.querySelector('.quotes-wrapper');
        if (quotesWrapper) {
            quotesWrapper.addEventListener('mouseenter', () => {
                clearInterval(quoteInterval);
            });

            quotesWrapper.addEventListener('mouseleave', () => {
                quoteInterval = setInterval(nextQuote, 5000);
            });
        }
    }

    // 视差滚动效果
    const heroSection = document.querySelector('.hero-section');
    if (heroSection) {
        window.addEventListener('scroll', function() {
            const scrolled = window.pageYOffset;
            heroSection.style.backgroundPositionY = -(scrolled * 0.5) + 'px';
        });
    }

    // 卡片悬停效果
    document.querySelectorAll('.couple-card').forEach(card => {
        const overlay = card.querySelector('.image-overlay');
        if (overlay) {
            card.addEventListener('mouseenter', function() {
                overlay.style.opacity = '0.7';
            });

            card.addEventListener('mouseleave', function() {
                overlay.style.opacity = '0.4';
            });
        }
    });

    // 初始化 AOS
    if (typeof AOS !== 'undefined') {
        AOS.init({
            duration: 800,
            once: true,
            offset: 100
        });
    }
});

// 添加页面加载动画
window.addEventListener('load', function() {
    document.body.classList.add('loaded');
}); 